// 引入路由组件
import Home from '../pages/Home'
import Login from '../pages/Login'
import Register from '../pages/Register'
import Search from '../pages/search'
import Detail from '../pages/Detail'
import AddCartSuccess from '../pages/AddCartSuccess'
import ShopCart from '../pages/ShopCart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import PaySuccess from '@/pages/PaySuccess'
import Center from '@/pages/Center'
// 引入二级路由组件
import MyOrder from "@/pages/Center/myOrder"
import GroupOrder from "@/pages/Center/groupOrder"

// 路由配置信息
export default  [
    {
        path: "/center",
        // name: 'Center',
        component: Center,
        // component: PaySuccess,
        meta: { show: true },
        // 二级路由组件
        children: [
            {
                path: "myOrder",
                component: MyOrder,
            },
            {
                path: "groupOrder",
                component: GroupOrder,
            },
            {
                path: "/center",
                redirect: "/center/myOrder"
            }
        ]
    },
    {
        path: "/PaySuccess",
        name: 'PaySuccess',
        component: PaySuccess,
        meta: { show: true }
    },
    {
        path: "/pay",
        name: 'Pay',
        component: Pay,
        meta: { show: true }
    },
    {
        path: "/trade",
        name: 'Trade',
        component: Trade,
        meta: { show: true }
    },
    {
        path: "/shopCart",
        name: 'shopCart',
        component: ShopCart,
        meta: { show: true }
    },
    {
        path: "/addCartSuccess",
        name: 'addCartSuccess',
        component: AddCartSuccess,
        meta: { show: true }
    },
    {
        path: '/home',
        component: Home,
        // 路由元信息不能瞎写，只能叫做meta
        meta:{show:true}
    },
    {
        path: '/login',
        component: Login,
        meta:{show:false}  
    },
    {
        // params参数对应的路由信息要修改为path: "/search/:keyword" 这里的/:keyword就是一个params参数的占位符
        name: 'search',
        path: '/search/:keyword?',
        component: Search,
        meta:{show:true},
        name:'search',
        // 路由组件能不能传递props数据
        // 布尔值写法:只有parmas参数
        // props: true
        // 对象写法
        // props:{a:1,b:2}
        //函数写法: 可以params参数、query参数，通过props传递给路由组件
        props: ($route) => {
            return {keyword:$route.params.keyword,k:$route.query.k}

        }

    },
    {
        path: '/register',
        component: Register,
        meta:{show:false}  
    },
    {
        path:"/detail/:skyid",
        component: Detail,
        meta:{show:false}  
    },
    // 重定向到首页
    {
        path: '/',
        redirect: '/home'
    }
]
